package bi.example.work;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Dao {
    public static void main(String[] args) {
        String url = "jdbc:mysql://localhost:3306/xs";
        String user = "root";
        String password = "123456";
        try{
            Class.forName("com.mysql.cj.jdbc.Driver");
            Connection connection= DriverManager.getConnection(url,user,password);
            String sql="select * from student";
            PreparedStatement statement=connection.prepareStatement(sql);
            ResultSet resultSet=statement.executeQuery();
            while (resultSet.next()) {
                System.out.println("Column 1:" + resultSet.getString(1));
            }
            resultSet.close();
            statement.close();
            connection.close();
        } catch (Exception e){
            e.printStackTrace();
        }
    }
}

